﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;
namespace StationDemo
{

    public partial class Form_VisionType : UIPage
    {
        List<VersionTypeValue> list_TypeValue = new List<VersionTypeValue>();
        string str_CurrentSoftVision = "";
        string str_CurrentDllVision = "";
        public Form_VisionType()
        {
            this.list_TypeValue = SoftVersionMgr.GetInstance().list_VisionValue;
            InitializeComponent();
        }

        private void Form_VisionType_Load(object sender, EventArgs e)
        {
            ui_VersionType.Rows.Clear();
            for (int i = list_TypeValue.Count-1; i >= 0; i--)
            {
                ui_VersionType.Rows.Add(list_TypeValue[i].str_SoftVersionName, list_TypeValue[i].Time_Generate.ToString("yyyy-MM-dd HH:mm:ss"));

            }
        }
        private void listbox_dllType_SelectedValueChanged(object sender, EventArgs e)
        {
            
        }

        private void ui_VersionType_SelectIndexChange(object sender, int index)
        {
            try
            {
                int n_Index = index;
                if (n_Index < 0)
                {
                    MessageBox.Show("请先选中要查看的软件版本"); return;
                }
                else
                {
                    string strName = ui_VersionType.Rows[n_Index].Cells[0].Value.ToString();
                    if (strName == "")
                        return;
                    else
                        str_CurrentSoftVision = strName;
                    foreach (var item in list_TypeValue)
                    {
                        if (item.str_SoftVersionName == str_CurrentSoftVision)
                        {
                            txt_SoftTypeValue.Text = item.str_SoftVersionValue;
                            dg_dll信息.Rows.Clear();
                            foreach (var itemdll in item.List_dllVersionValue)
                            {
                                dg_dll信息.Rows.Add(itemdll.str_DllName, itemdll.str_DllVersion);
                            }
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void dg_dll信息_SelectIndexChange(object sender, int index)
        {
            try
            {
                int n_Index = index;
                if (n_Index < 0)
                {
                    MessageBox.Show("请先选中要查看的软件版本"); return;
                }
                else
                {
                    string str_DllVision = dg_dll信息.Rows[n_Index].Cells[0].Value.ToString();
                    if (str_DllVision == "")
                        return;
                    else
                        str_CurrentDllVision = str_DllVision;
                    foreach (var item in list_TypeValue)
                    {
                        if (item.str_SoftVersionName == str_CurrentSoftVision)
                        {
                            foreach (var itemdll in item.List_dllVersionValue)
                            {
                                if (str_CurrentDllVision == itemdll.str_DllName)
                                {
                                    txt_dllTypeValue.Text = itemdll.str_DllVersionValue;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
